<template>
	<view class="">
		<view class="bell_icon" @click="gotoNotice" >

			<u-icon name="bell" size="32"></u-icon>
			<!-- <u--text prefixIcon="bell" iconStyle="font-size: 52rpx" text=""></u--text> -->
			<u-badge v-if="circle_num > 0" type="error" :offset="[4,8]" :absolute="true" max="99"
				:value="circle_num"></u-badge>
			<!-- <u-badge v-if="circle_num > 0" :offset="[4,15]" :isDot="true" :absolute="true"></u-badge> -->

		</view>
	</view>
</template>

<script>
	import * as MemberApi from '@/api/member.js'
	export default {
		name: "Notify",

		data() {
			return {
				show: false,
				circle_num: 0,
			};
		},
		beforeCreate(){},
		created(){
			console.log("created")
		},
		beforeMount(){
			console.log("beforeMount")
			this.getCircle_num()
		},
		beforeDestroy(){
			console.log("beforeDestroy")
		},
		methods: {
			getCircle_num() {
				MemberApi.circle_num().then(res => {
					this.circle_num = res.data.circle_num
					
					
					
					let routes = getCurrentPages();
					let curRoute = routes[routes.length - 1].route 
					if(curRoute == 'pages/user/user'){
						this.show = true
					}else if(this.circle_num > 0){
						this.show = true
					}
				})
			},
			gotoNotice() {
				this.circle_num = 0
				uni.navigateTo({
					url: '/pages/notice/notice'
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.bell_icon {
		width: 80rpx;
		position: fixed;
		top: 50rpx;
		right: 0;
		background-color: #ffd91d;

		padding: 10rpx;
		border-radius: 20rpx 0 0 20rpx;
		box-shadow: 0 4rpx 8rpx 0 rgba(0, 0, 0, 0.2), 0 6rpx 20rpx 0 rgba(0, 0, 0, 0.19);
		z-index: 999;
	}
</style>